package com.demo.web.controller;

import com.demo.dao.enity.User;
import com.demo.dao.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/demoAnnotation")
public class DemoAnnotationController {

    @Autowired
    private UserMapper userMapper;

    @RequestMapping("/test/{name}/{age}")
    public Object test(@PathVariable String name, @PathVariable int age){

        Map<String,Object> result = new HashMap<>();
        result.put("name",name);
        result.put("age",age);
        return result;
    }

    @RequestMapping("/test01/{name}/{age}")
    public Object test01(@PathVariable Map result){
        result.put("test","hello");
        return result;
    }

    @RequestMapping("/user/{id}")
    public User getUser(@PathVariable int id){
        return userMapper.getById(id);
    }
}
